<!-- 页面中的内容 -->

<div class="main-div">
    <form name="main_form" method="POST" action="{:url('edit')}" enctype="multipart/form-data">
        <table cellspacing="1" cellpadding="3" width="100%">
            <tr>
                <td class="label">品牌名称：</td>
                <td>
                    <input  type="text" name="ch_name" value="{$brand.brand_name}" />
                </td>
            </tr>
            <tr>
                <td class="label">英文名称：</td>
                <td>
                    <input  type="text" name="en_name" value="{$brand.brand_name_en}" />
                </td>
            </tr>
            <tr>
                <td class="label">网站地址：</td>
                <td>
                    <input  type="text" name="site_url" value="{if condition="$brand['brand_web_url']"}{$brand.brand_web_url}{else /}http://{/if}" />
                </td>
            </tr>
            <tr>
                <td class="label">前台状态：</td>
                <td>
                    <input type="radio" name="status" value="1" {if condition="$brand['brand_status']"}checked="checked"{/if} /> 展示
                    <input type="radio" name="status" {if condition="!$brand['brand_status']"}checked="checked"{/if} value="0" /> 隐藏
                </td>
            </tr>
            
            <tr>
                <td class="label">品牌logo：</td>
                <td>
                    <input type="file" id="logo_img" /> 
                	<input type="hidden" name="uploadImg" value="{$brand.brand_logo}" /> 
                </td>
            </tr>
            <tr {if condition="!$brand['brand_logo']"}style="display: none;"{/if} >
                <td class="label">缩略图展示：</td>
                <td style="position: relative;display: inline-block;">
                    <img class="picShow" src="{$brand.brand_logo}" width="115" alt="" style="border: 1px solid #aaa;" >
                    <a title="删除图片" class="del_logo" href="javascript:;" style="position: absolute;right: 1px;top: 0px;width: 16px;height: 20px;font-size: 20px;text-decoration: none;">×</a>
                </td>
            </tr>
            <tr>
                <td class="label">品牌描述：</td>
                <td>
                    <textarea name="desc" id="" cols="30" rows="10">{$brand.brand_name}</textarea>
                </td>
            </tr>
            <tr>
                <td class="label">排序：</td>
                <td>
                    <input type="text" name="sort" value="{$brand.sort}" style="width: 30px;text-align: center;" /> 
                    <input type="hidden" name="id" value="{:input('id')}">
                </td>
            </tr>
            <tr>
                <td colspan="99" align="center">
                    <input type="submit" class="button" value=" 确定 " />
                    <input type="reset" class="button" value=" 重置 " />
                </td>
            </tr>
        </table>
    </form>
</div>

<link rel="stylesheet" href="__PUBLIC__/plugin/uploadify/uploadify.css">
<style>
    #logo_img-button{
        border-radius: 0;
        border:0 none;
    }
</style>
<script src="__PUBLIC__/plugin/uploadify/jquery.uploadify.min.js"></script>
<script>
    //上传展示图
    var imgPath=$('.del_logo').prev().attr('src');//保存缩略图的路径，用于删除展示图
    var uploadImg = $("input[name=uploadImg]");
    var id = "{:input('id')}";
    $('#logo_img').uploadify({
        swf           : '__PUBLIC__/plugin/uploadify/uploadify.swf',
        uploader      : "{:url('uploadLogo')}",
        width         : 80,
        height        : 24,
        buttonImage   : '__PUBLIC__/plugin/uploadify/upload.png',
        cancelImg : '__PUBLIC__/plugin/uploadify//uploadify-cancel.png',          
        onUploadSuccess:function(file, data, response){
           
           imgPath = "{:config('upload_path')}/"+data;
           uploadImg.val(imgPath);
           $('.picShow').attr('src',imgPath).parents('tr').show();
            
        }
    });
    //删除展示图
    $('.del_logo').click(function() {
        var url = "{:url('delLogo')}";
        var _this = this;
        $.get(url,{path:imgPath,id:id},function( data ) {
            if( data.status ){

                $(_this).parents('tr').fadeOut('slow', function() {

                    uploadImg.val('');
                    $(_this).prev('img').attr('src','');
                    
                });

            }else{
                alert(data.msg);
            }

        },'json');
    });
</script>